<template>
    <div class="container">
      <div class="container--item">
        <img src="../assets/register/left.png"
             @click="$router.push({ name: 'search'})"
             class="container--img__staffService"
             alt="#">
        <div class="container--item__search" @click="$router.push({ name: 'search'})">
          <img src="../assets/mall/search.png" class="container--img__search" alt="#">
          <span>保暖内衣</span>
        </div>
        <img src="../assets/mall/shoppingCart.png"
             class="container--img__cart" alt="#" @click="shoppingCart">
      </div>
      <div class="container--item__title">
        <span class="container--item__text">综合</span>
        <span>
          销量
          <img src="../assets/mall/triangle.png" class="container--img__top" alt="#">
          <img src="../assets/mall/triangle.png" class="container--img__bottom" alt="#">
        </span>
        <span>
          价格
          <img src="../assets/mall/triangle.png"
               class="container--img__top" alt="#" @click="large">
          <img src="../assets/mall/triangle.png"
               class="container--img__bottom" alt="#" @click="Small">
        </span>
      </div>
      <div class="container--item__Recommend">
        <p class="container--recommend__title">为您推荐</p>
        <div class="container--recommend__commodity" v-for="(item, key) in searchValue" :key="key">
          <div class="container--img__box">
            <img :src="item.prodImage[0]" alt="#" class="container--recommend__img">
          </div>
          <span class="container--recommend__text">
              {{item.prodSubTitle}}
            </span>
          <span class="container--recommend__money">券后价</span>
          <span class="container--recommend__price">￥{{item.currentPrice}}</span>
          <span class="container--text__price">￥{{item.originPrice}}</span>
        </div>
      </div>
    </div>
</template>

<script>
/* eslint-disable*/
export default {
  name: 'searchCommodity',
  data() {
    return {
      searchValue: null,
      searchProdData: null,
    };
  },
  methods: {
    shoppingCart() {
      this.$router.push({ name: 'shoppingCart', params: { data: this.searchProdData } });
    },
    large() {
      this.searchValue.sort((a, b) => b.currentPrice - a.currentPrice)
    },
    Small() {
      this.searchValue.sort((a, b) => a.currentPrice - b.currentPrice)
    },
  },
  created() {
    this.searchProdData = this.$route.params.data;
    this.$api.searchProd({ keyword: this.searchProdData })
      .then((data) => {
        console.log(data);
        this.searchValue = data.data.data;
      })
      .catch(error => console.log(error));
  },
};
</script>

<style scoped lang="scss">
*{
  margin: 0;
  padding: 0;
  font-size: 0;
}
.container{
  width: 100vw;
  .container--item{
    background-color: #fff;
    width: 100vw;
    position: relative;
    line-height: (86/75) + rem;
    border-bottom: 1px solid #f2f2f2;
    .container--img__staffService{
      width: .5rem;
      height: .5rem;
      vertical-align: middle;
      margin-left: .5rem;
    }
    .container--item__search{
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      margin: auto;
      border-radius: 4px;
      vertical-align: middle;
      height: (72/75) + rem;
      width: 70%;
      background-color: #f5f5f5;
      .container--img__search{
        vertical-align: middle;
        width: .4rem;
        height: .4rem;
        margin-left: 4%;
        margin-bottom: 2%;
      }
      span{
        font-size: .35rem;
        margin-left: .35rem;
        vertical-align: middle;
        position: relative;
        top: -.1rem;
        outline: none;
        border: none;
        height: .8rem;
        width: 5.9rem;
        background-color: #f5f5f5;
        color: #c0c0c0;
      }
    }
    .container--img__cart{
      font-size: .35rem;
      position: absolute;
      right: .4rem;
      bottom: 0;
      top: 0;
      margin: auto 0;
      width: .6rem;
      height: .6rem;
    }
  }
  .container--item__title{
    width: 100vw;
    height: 1.2rem;
    margin-bottom: (15/75) + rem;
    .container--item__text{
      margin-left: .35rem;
    }
    span{
      position: relative;
      font-size: .35rem;
      line-height: 1.2rem;
      margin-left: .5rem;
      img{
        width: .5rem;
        height: .5rem;
      }
      .container--img__bottom{
        transform: rotate(180deg);
        position: absolute;
        left: .8rem;
        top: .1rem;
      }
    }
    .container--item__text{

    }
  }
  .container--item__Recommend{
    width: 100vw;
    background-color: #fff;
    .container--recommend__title{
      font-size: .44rem;
      height: 100%;
      line-height: 1.56rem;
      margin-left: .3733333rem;
    }
    .container--recommend__commodity{
      position: relative;
      width: 100vw;
      height: (230/75) + rem;
      margin-left: .35rem;
      .container--img__box{
        display: inline-block;
        width: (200/75) + rem;
        height: 100%;
        .container--recommend__img{
          width: (200/75) + rem;
          height: 100%;
        }
      }
      .container--recommend__text{
        font-size: .35rem;
        vertical-align: top;
        width: 66%;
        display: inline-block;
        margin-left: .2rem;
      }
      .container--recommend__money{
        text-align: center;
        font-size: (24/75) + rem;
        color: #fff;
        line-height: .5rem;
        width: 1.5rem;
        border-radius: 30px;
        background-color: #208eff;
        position: absolute;
        bottom: 1rem;
        left: 29%;
      }
      .container--recommend__price{
        font-size: (24/75) + rem;
        position: absolute;
        bottom: 1.05rem;
        left: 46%;
        color: #208eff;
      }
      .container--text__price{
        font-size: (24/75) + rem;
        color: #ccc;
        position: absolute;
        bottom: .4rem;
        left: 29%;
      }
    }
  }
}
</style>
